package ru.papergames.battleserver.util.pathfinding.heuristic;

import ru.papergames.battleserver.model.battle.npc.NpcBattleMap;
import ru.papergames.battleserver.util.pathfinding.AStarHeuristic;

/**
 * A heuristic that uses the tile that is closest to the target
 * as the next best tile.
 * 
 * @author Kevin Glass
 */
public class ClosestHeuristic implements AStarHeuristic {
	/**
	 * @see AStarHeuristic#getCost(NpcBattleMap, int, int, int, int)
	 */
	public int getCost(NpcBattleMap map, int x, int y, int tx, int ty) {
		int dx = tx - x;
		int dy = ty - y;
		
		return (int) (Math.sqrt((dx*dx)+(dy*dy)));
	}

}
